package vip.indo.listener;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;
import vip.indo.entity.User;
import vip.indo.event.MyEvent;

/**
 * 自定义监听器，监听MyEvent事件
 * @Author: tianlianyin
 * @Date: 2024/11/28 17:02
 * @Descripition:
 */
@Component
@Slf4j
public class MyEventListener implements ApplicationListener<MyEvent> {
    @Override
    public void onApplicationEvent(MyEvent myEvent) {
        //吧事件中的信息获取到
        User user=myEvent.getUser();
        //处理事件
        log.info("用户名：{}，密码：{}",user.getUsername(),user.getPassword());
    }
}
